import { _detail } from '../../common/meeting'
import { formatDate } from '../../utils/util'
const WxParse = require('../../libs/wxParse/wxParse.js')
const computedBehavior = require('miniprogram-computed')
const app = getApp()
Component({
  behaviors: [computedBehavior],
  data: {
    id: '',
    detail: null
  },
  computed: {
    addBar() {
      return /iphone\sx/i.test(app.globalData.phone.toLowerCase())
    }
  },
  methods: {
    totalQuery() {
      app.loading('加载中')
      _detail(this.data.id).then(res => {
        wx.hideLoading()
        this.data.detail = res.data.Meeting_Room
        this.data.detail.SlideImg = JSON.parse(this.data.detail.SlideImg)
        let content = this.data.detail.Introduce
        WxParse.wxParse('content', 'html', content, this, 0)
        this.setData({
          detail: this.data.detail
        })
      }).catch(err => {
        console.log(err)
        wx.hideLoading()
        wx.showModal({
          title: '对不起',
          content: JSON.stringify(err) || '网络错误，请稍后再试',
          showCancel: false
        })
      })
    },
    doCall() {
      wx.makePhoneCall({
        phoneNumber: this.data.detail.Tel
      })
    },
    onLoad(options) {
      this.data.id = options.id
    },
    onReady() { },
    onShow() {
      app.memberReadyCb = () => {
        this.totalQuery()
      }
      app.fansReadyCb = () => {
        app.checkMember()
      }
      app.init()
    },
    onShareAppMessage() {
      return app.shareInfo
    }
  }
})